package com.ssmTest.service.impl;

import com.ssmTest.dao.IRecordDao;
import com.ssmTest.model.Record;
import com.ssmTest.service.IRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service("recordService")
public class RecordServicelImpl implements IRecordsService{
    @Resource
    private IRecordDao recordDao;

    @Autowired
    private IRecordsService recordService;
    public void newRecord(String no,String type,double money){
        Record record = new Record();
        record.setNo(no);
        record.setType(type);
        record.setMoney(money);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        record.setTime(df.format(new Date()));// new Date()为获取当前系统时间
        recordService.insertRecord(record);
    }

    public void insertRecord(Record record) {
        this.recordDao.insertRecord(record);
    }

    //根据学号搜寻消费记录
    public Record selectByNo(String no){
        return this.recordDao.selectByNo(no);
    }
}
